package com.tuo51.evaluate.service;

import com.matt.commons.dto.sso.StaffDTO;
import com.matt.domain.Children;
import com.matt.foundation.query.EvaluateQuery;
import com.matt.commons.page.PagerQuery;
import com.tuo51.core.domain.org.Organization;
import com.tuo51.evaluate.domain.evaluatingV2.*;
import com.tuo51.evaluate.vo.evaluate.*;
import org.springframework.data.domain.Page;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface EvaluateV2Service {

    static final String WARNING_DIMENSION_ID = "2c92848567977b50016797a129d909b4";

    static final String ORDERBY_CREATED = "created";
    static final String ORDERBY_NEXT = "next";
    static final String ORDERBY_LAST = "last";
    static final String ORDERBY_BIRTHDAY = "birthday";


    //pc查询老师测评列表
    Page findEvaluatesByTeacherId(String teacherId, String areaId, PagerQuery page);

    //pc 园长查所有测评列表
    Page findEvaluatesByTeacherId(String teacherId, PagerQuery page);

    Page<WebEvaluateRecordListVo> getEvaluatePage(EvaluateQuery query);

    List<EvaluateChildrenVO> getChildrenEvaluateInfo(String staffId, String orderBy);

    List<EvaluateChildrenVO> getChildrenByNameEvaluate(String staffId, String name, String orderBy);

    List<EvaluateV2Record> getEvaluateRecordByChildrenId(String childrenId);

    //pc 填写测评建议
    //pc 关联课程，可复用?
    //pc 审批发布测评
//    RecommendCoursePlan addRecommendCourse(String evaluateRecordId, Integer planType, Integer nurseryMonth, Integer satTimes, Integer sTimes, Integer aTimes, Integer tTimes);
//
//    RecommendCoursePlan modifyRecommendCourse(String recommendCoursePlanId, Integer planType, Integer nurseryMonth, Integer satTimes, Integer sTimes, Integer aTimes, Integer tTimes);

    Map submitAdvise(StaffDTO staff, String evaluateRecordId, String advise, Integer infoType, String infoDomainId, String height, String weight, String header);

    /**
     * 修改身高、体重、头围
     *
     * @param evaluateRecordId 测评纪录id
     * @param height           身高
     * @param weight           体重
     * @param header           头围
     * @param staffId          修改者 id
     * @param staffName        修改者名字
     */
    EvaluateV2Record modifyEvaluateRecord(String evaluateRecordId, String height, String weight, String header, String staffId, String staffName);

    /**
     * 修改总体评估建议
     *
     * @param evaluateRecordId 测评纪录id
     * @param advise           评估建议
     * @param staffId          修改者 id
     * @param staffName        修改者名字
     */
    EvaluateV2Record modifyEvaluateAdvise(String evaluateRecordId, String advise, String staffId, String staffName);

    /**
     * 测评完成后，修改测评纪录状态，改为已发布
     *
     * @param evaluateRecordId 测评纪录id
     */
    EvaluateV2Record finishEvaluate(String evaluateRecordId, boolean paid);
    EvaluateV2Record finishEvaluateWithTimes(String evaluateRecordId, Organization org);

    EvaluateV2Record payEvaluate(String evaluateRecordId);
    EvaluateV2Record payEvaluateWithTimes(String evaluateRecordId, Organization org);

    //失败的问题，以及建议
    List<EvaluateV2Question> failedQuestion(String childrenId, String evaluateRecordId);

    //直接创建完整报告
    EvaluateV2Record createEvaluate(String evaluateType, StaffDTO staff, Children c, String weight, String height, List<EvaluateV2SheetAnswerPO> answers, List<String> skipDiemnsions, Long duration);

    //app 创建测评
    EvaluateV2Record startEvaluate(StaffDTO staff, Children children, String weight, String height, boolean skipWarningDiemension, Integer demo);

    //更新数据
    EvaluateV2Record startEvaluate(StaffDTO staff, String evaluateId, String weight, String height, boolean skipWarningDiemension);


    //最近一次未完成的草稿测评
    EvaluateV2Record draftEvaluateItemLastNotFinished(String teacherId, String childrenId, String childrenName);

    //从缓存里处理数据
    boolean anyQuestionInItemNotChecked(String recordId, EvaluateV2Item item);
    Map cacheAnswerForEvaluateItem(String evaluateRecordId, String options);
    void markShortItemsUnpassed(String recordId, EvaluateV2Question question);

    //app提交测评题目得分，并获取下一个题目
    EvaluateV2Item nextEvaluateItem(String evaluateRecordId, String[] questionIds, boolean[] checked, boolean resume);

    //获取完整的测试题
    List<EvaluateV2ItemVO> fullEvaluateItems(String dimensionId, Date birthday);

    //app 获取维度列表
    List<EvaluateV2Dimension> allValidEvaluatedDimension(boolean skipWarningDiemension);

    //app 获取月份列表
    List<Integer> allValidMonthList(String dimensionId);

    //app 获取操作指导
    EvaluateV2Question getQuestionDetail(String questionId);

    //app 获取最近一次的测评记录
    EvaluateV2Record getLastEvaluateRecord(String childrenId);

    //app 获取测评记录详情
    EvaluateV2Record getEvaluateDetail(String evaluateId);
    EvaluateV2Record getEvaluateDetail(String evaluateId, String recommendChannel);
    EvaluateV2Record getEvaluateDetailForStaff(String evaluateId, String staffId);
    EvaluateV2Record getEvaluateDetailForStaff(String evaluateId, String staffId, String recommendChannel);
    EvaluateV2Record getEvaluateDetail(String evaluateId, boolean withHightLevelInfo);
    EvaluateV2Record getEvaluateDetailForStaff(String evaluateId, String staffId, boolean withHightLevelInfo);
    EvaluateV2Record getEvaluateDetailForStaff(String evaluateId, String staffId, boolean withHightLevelInfo, String recommendChannel);

    //报告授权给家长
    boolean grantEvaluateToParent(StaffDTO sourceTeacher, EvaluateV2Record record);
    boolean grantAllEvaluateToParent(StaffDTO parent);
    boolean revokeGrantEvaluateToParent(String staffId, EvaluateV2Record record);

    //通知家长
    void notifyParentToEvaluate(String staffId, String childrenId);

    //删除
    boolean deleteReportForStaff(String evaluateId, String staffId);

    //app 根据id 查询tools
    List<EvaluateV2Tool> getEvaluateToolsForQuestion(String itemId);

    //根据itemId来查询tools
    List<EvaluateV2Tool> getEvaluateToolsForItem(String itemId);

    //app 根据id 查询tools
    List<EvaluateV2ToolVO> getFullEvaluateTools(Integer month);

    //根据用户id迁移报告列表
//    boolean transferReports(StaffDTO sourceStaff, StaffDTO targetStaff);

    Integer countReportsByStaffIds(List<String> ids, Date date);
}
